import { createSlice } from "@reduxjs/toolkit";
const channelStore = createSlice({
    name:'channel',
    initialState:{
        channelList:[]
    },
    reducers:{
        setChannels(state, action){
            state.channelList = action.payload
        }
    }
})

// 异步请求部分
const  { setChannels } = channelStore.actions
const fetchChannelList = ()=>{
    return async ()=>{
        const res = await axios.get('http://xxx')
        dispatchEvent(setChannels(res.data,channels))
    }
}

export { fetchChannlList }
const reducer = channelStore.reducer
export default reducer